[{"id":"41129652.888b28","type":"tab","label":"Flow 6","disabled":false,"info":""},{"id":"5cf2b1f8.0915c8","type":"mqtt in","z":"41129652.888b28","name":"","topic":"hw/diversitydemo/+/+/fC","qos":"0","datatype":"auto","broker":"aa1c8d2.33c677","x":234,"y":265.8999938964844,"wires":[["2985d538.5f032a","6054376c.c1eba"]]},{"id":"2985d538.5f032a","type":"debug","z":"41129652.888b28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":605,"y":266,"wires":[]},{"id":"2e936f14.25bcc8","type":"ui_chart","z":"41129652.888b28","name":"","group":"42d385ab.08cc54","order":5,"width":"24","height":"8","label":"","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"15","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":682,"y":445,"wires":[[]]},{"id":"6054376c.c1eba","type":"function","z":"41129652.888b28","name":"","func":"\nvar ttt = new Date().getTime();\n\nmsg.topic = msg.topic.split(\"/\")[2];\nmsg.payload =parseFloat(msg.payload);\n\n\nif(msg.payload<0.2) { msg.payload = 0; }\n\n\nif(!flow.get(\"fC.\"+ msg.topic)) {\n    \n    var nc = flow.get(\"fCcount\") || 0;\n    nc++;\n    flow.set(\"fCcount\",nc) ;\n    nt = nc;\n    \n    \n} else {\n    \n    nt = flow.get(\"fC.\"+ msg.topic)[\"id\"]; \n}\n\nflow.set(\"fC.\"+ msg.topic, {\"id\":nt, \"value\":msg.payload, \"timestamp\": ttt});\n\nmsg.topic = nt;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":436,"y":337,"wires":[["2e936f14.25bcc8","c9c88a99.5ebd9"]]},{"id":"181f52de.5fe6ed","type":"change","z":"41129652.888b28","name":"","rules":[{"t":"set","p":"fCcount","pt":"flow","to":"0","tot":"num"},{"t":"delete","p":"fC","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":405.8833312988281,"y":548.8833312988281,"wires":[["ab97e2ba.f63b48"]]},{"id":"fbd78e47.a987d","type":"ui_button","z":"41129652.888b28","name":"","group":"7768e0c.38c60a","order":1,"width":"0","height":"0","passthru":false,"label":"Start Readings","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":216,"y":157,"wires":[["6600c965.f21ba"]]},{"id":"6600c965.f21ba","type":"mqtt out","z":"41129652.888b28","name":"","topic":"hw/diversitydemo/start","qos":"0","retain":"false","broker":"aa1c8d2.33c677","x":436,"y":157,"wires":[]},{"id":"588ce7d7.33f588","type":"ui_button","z":"41129652.888b28","name":"","group":"7768e0c.38c60a","order":1,"width":"0","height":"0","passthru":false,"label":"Clear Graph","tooltip":"","color":"","bgcolor":"","icon":"","payload":"[]","payloadType":"json","topic":"","x":418,"y":509,"wires":[["ab97e2ba.f63b48"]]},{"id":"39dffd6a.bb3b62","type":"ui_button","z":"41129652.888b28","name":"","group":"7768e0c.38c60a","order":1,"width":"0","height":"0","passthru":false,"label":"Clear Data","tooltip":"","color":"","bgcolor":"","icon":"","payload":"[]","payloadType":"json","topic":"","x":213,"y":549,"wires":[["181f52de.5fe6ed"]]},{"id":"46add9d4.da511","type":"comment","z":"41129652.888b28","name":"This flow demonstrates how an MQTT subscription is made to HIU data. In this case, anonomised data is fed via the Hive public MQTT server.","info":"","x":526,"y":50,"wires":[]},{"id":"613a656b.a388ac","type":"comment","z":"41129652.888b28","name":"Data is initiated by sending a start request to the Heatweb server.","info":"","x":338,"y":108,"wires":[]},{"id":"ff6b68eb.24298","type":"comment","z":"41129652.888b28","name":"Data is recieved bia MQTT","info":"","x":211,"y":222,"wires":[]},{"id":"31b7721.ad1760e","type":"comment","z":"41129652.888b28","name":"Data is stored and each property given an number.","info":"","x":306,"y":381,"wires":[]},{"id":"772fa5d0.accd3c","type":"comment","z":"41129652.888b28","name":"Data is then fed into the graph.","info":"","x":813,"y":554,"wires":[]},{"id":"8aa9e7f6.09db8","type":"comment","z":"41129652.888b28","name":"Buttons are provided to clear the graph and stored data.","info":"","x":280,"y":592,"wires":[]},{"id":"dfde025f.943eb","type":"comment","z":"41129652.888b28","name":"The debug node lets us see incoming data in the debug window.","info":"","x":766,"y":224,"wires":[]},{"id":"c31cb21.b0e59d","type":"comment","z":"41129652.888b28","name":"If no data received from a property then we clear the stored value.","info":"","x":307,"y":674,"wires":[]},{"id":"ca47701c.adf068","type":"ui_gauge","z":"41129652.888b28","name":"","group":"7768e0c.38c60a","order":4,"width":"0","height":"0","gtype":"gage","title":"Total Flow","label":"litres/minute","format":"{{value| number:1}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":896,"y":396,"wires":[]},{"id":"c9c88a99.5ebd9","type":"change","z":"41129652.888b28","name":"Total Flow","rules":[{"t":"set","p":"payload","pt":"msg","to":"fC","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"$sum(payload.*.value)","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"total flow","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":693,"y":395,"wires":[["ca47701c.adf068","3ca7b90d.ecfcee"]]},{"id":"47ad982.7340f68","type":"inject","z":"41129652.888b28","name":"","topic":"","payload":"","payloadType":"date","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":175,"y":723,"wires":[["3ec78684.9f4942"]]},{"id":"3ec78684.9f4942","type":"function","z":"41129652.888b28","name":"Clean old values","func":"var ttt = new Date().getTime();\nfor (var k in flow.get(\"fC\")) {\n    \n    if (flow.get(\"fC.\"+k+\".value\")>0) {\n        var ts = flow.get(\"fC.\"+k+\".timestamp\");\n        if (ttt-ts > 15000) {  flow.set(\"fC.\"+k+\".value\",0); }\n    }\n}\nreturn msg;","outputs":1,"noerr":0,"x":366,"y":723,"wires":[[]]},{"id":"417ee5a4.4de18c","type":"comment","z":"41129652.888b28","name":"The flows for each property are totalled and fed into a gauge.","info":"","x":828,"y":347,"wires":[]},{"id":"3ca7b90d.ecfcee","type":"ui_chart","z":"41129652.888b28","name":"","group":"42d385ab.08cc54","order":5,"width":"24","height":"5","label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"15","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":886,"y":513,"wires":[[]]},{"id":"ab97e2ba.f63b48","type":"link out","z":"41129652.888b28","name":"","links":["a016be92.28871","7aff8bd6.73278c"],"x":544,"y":537,"wires":[]},{"id":"a016be92.28871","type":"link in","z":"41129652.888b28","name":"","links":["ab97e2ba.f63b48"],"x":752,"y":512,"wires":[["3ca7b90d.ecfcee"]]},{"id":"7aff8bd6.73278c","type":"link in","z":"41129652.888b28","name":"","links":["ab97e2ba.f63b48"],"x":556,"y":443,"wires":[["2e936f14.25bcc8"]]},{"id":"aa1c8d2.33c677","type":"mqtt-broker","z":"","name":"","broker":"broker.hivemq.com","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"42d385ab.08cc54","type":"ui_group","z":"","name":"Tap Flow Data","tab":"80a123ea.a644f","disp":false,"width":"24","collapse":false},{"id":"7768e0c.38c60a","type":"ui_group","z":"","name":"Gauges","tab":"80a123ea.a644f","disp":false,"width":"6","collapse":false},{"id":"80a123ea.a644f","type":"ui_tab","z":"","name":"Diversity","icon":"dashboard","disabled":false,"hidden":false}]